package ntancnit.app.whereareyou;

import ntancnit.app.network.Config;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.Handler;

public class SplashScreen extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.splash_screen);
		SharedPreferences prefs = this.getSharedPreferences(
				Config.SHAREDPREFERENCES_DATA, Context.MODE_PRIVATE);
		final Boolean isLogedIn = prefs.getBoolean("isLogedIn", false);
		int SPLASH_DURATION = 3000;
		Handler myhandler = new Handler();

		myhandler.postDelayed(new Runnable() {

			@Override
			public void run() {
				if (!isLogedIn) {
					Intent intent = new Intent(SplashScreen.this,
							LoginScreen.class);
					startActivity(intent);

				} else {
					Intent intent = new Intent(SplashScreen.this,
							MainActivity.class);
					startActivity(intent);
				}
				finish();
			}

		}, SPLASH_DURATION);
	}

}
